package com.yyfax.ph.home.todolist;

import com.yyfax.infrastructure.eventbus.EventAgent;
import com.yyfax.infrastructure.mvp.Model;
import com.yyfax.infrastructure.network.NetworkHelper;
import com.yyfax.infrastructure.network.entity.BaseResultEntity;
import com.yyfax.infrastructure.network.entity.EmptyEntity;
import com.yyfax.ph.base.YJPH;
import retrofit2.http.Body;
import retrofit2.http.Header;
import retrofit2.http.POST;
import rx.Observable;

/**
 * M: 获取待办数目
 * Created by ying_he on 2017/11/4.<br>
 * Copyright  2017 www.yylending.com. All Rights Reserved.<br><br>
 */

public class ToDoListSizeModel extends Model<BaseResultEntity>{
	@Override
	public Observable getObservable(Object params, int functionalCode) {
		ToDoListSizeModel.Service service = (ToDoListSizeModel.Service) NetworkHelper.createService(ToDoListSizeModel.Service.class);
		String token = YJPH.getInstance().getPreferenceManager().getLoginToken();
		return service.getToDoListSize(token, new EmptyEntity());

	}

	@Override
	public void onNext(BaseResultEntity entity) {
		ToDoListSizeResult result = cast(entity);
		EventAgent.post(result);
	}

	interface Service{
		@POST("sys/todo/count")
		Observable<ToDoListSizeResult> getToDoListSize(@Header("token") String token, @Body EmptyEntity cancel);
	}

	public static class ToDoListSizeResult extends BaseResultEntity<ToDoBean>{

	}

	public static class ToDoBean{
		public String count = "";
	}
}
